package com.hs.hlw.credit.system.web.config;

import com.fasterxml.classmate.TypeResolver;
import com.hs.hlw.credit.system.web.setting.SwaggerSetting;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import static springfox.documentation.schema.AlternateTypeRules.newRule;

@Configuration
@EnableSwagger2
@AutoConfigureAfter(WebConfiguration.class)
public class SwaggerConfiguration {

    @Autowired
    private SwaggerSetting swaggerSetting;

    @Autowired
    private TypeResolver typeResolver;

    @Bean
    public Docket api() {
        return new Docket(DocumentationType.SWAGGER_2)
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.hs.hlw.credit.system.web.controller"))
                .paths(PathSelectors.any())
                .build();
    }
}
